﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Simplicity
{
    partial class ChocHelper
    {
        private void FireGameChanges()
        {
            FirePropertyChanged("Players");
            FirePropertyChanged("TgdbRating");
            FirePropertyChanged("ProductionYear");
            FirePropertyChanged("EsrbRating");
            FirePropertyChanged("Company");
            FirePropertyChanged("ConsoleReleaseYear");
        }

        private int GetDynamicPropertyAsInt(string PropertyName)
        {
            try
            {
                return Convert.ToInt32(CurrentItem.DynamicProperties[PropertyName]);
            }
            catch (Exception ex)
            {
                return 0;
            }
        }


        public string Players
        {
            get
            {

                string players = GetDynamicProperty("Players");

                if (players != null)
                {
                    return players;

                }
                return "";

            }

        }


        public Single TgdbRating
        {
            get
            {

                string rating = GetDynamicProperty("TgdbRating");

                if (!string.IsNullOrEmpty(rating))
                {
                    return Convert.ToSingle(rating);

                }
                return 0;

            }

        }


        public string EsrbRating
        {
            get
            {
                string rating = GetDynamicProperty("EsrbRating");

                if (rating != null)
                {
                    return rating;
                }

                return "";
            }
        }

        public string ConsoleReleaseYear
        {
            get
            {
                int year = GetDynamicPropertyAsInt("ReleaseYear");

                if ( year != 0)
                {
                    return year.ToString() ;
                }

                return "";
            }
        }

        public string Company
        {
            get
            {
                string company = GetDynamicProperty("Manufacturer");

                if (company != null)
                {
                    return company;
                }

                return "";
            }            
        }
    }
}